home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / server~1.zip / _SHRAP.QC < prev    next >
Text File  |  1996-10-04  |  12KB  |  394 lines

  1. /*
  2. **
  3. ** _shrapnel.qc (Shrapnel Code, 1.0)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. void(entity player) ShrapnelInfo =
  26. {
  27.   if (!USE_MODULE_SHRAPNEL) return;
  28.  
  29.               // 123456789#123456789#123456789#12345678
  30.   sprint(player,"£");
  31.   sprint(player," Shrapnel");
  32.   sprint(player,         " gives splintering rockets.\n");
  33.   sprint(player,"  Type 'help-shrapnel' for help.\n");
  34. };
  35.  
  36. void(entity player) ShrapnelInit =
  37. {
  38.   if (!USE_MODULE_SHRAPNEL) return;
  39.  
  40.   stuffcmd(player,"alias help-shrapnel \"impulse 216\";\n");
  41. };
  42.  
  43. void(entity player) ShrapnelActiveMessage =
  44. {
  45.   if (!USE_MODULE_SHRAPNEL) return;
  46.  
  47.               // 123456789#123456789#123456789#12345678
  48.   sprint(player,"  Shrapnel      (help-shrapnel)\n");
  49. };
  50.  
  51. void(entity player) ShrapnelHelp =
  52. {
  53.   if (!USE_MODULE_SHRAPNEL) return;
  54.  
  55.               // 123456789#123456789#123456789#12345678
  56.   sprint(player,"Shrapnel:");
  57.   sprint(player,        " gives splintering rockets.\n");
  58.   sprint(player,"Double-select the rocket launcher to\n");
  59.   sprint(player,"use shrapnel missiles.\n");
  60.   sprint(player,"The silver key is lit when the rocket\n");
  61.   sprint(player,"launcher fires splintering rockets.\n");
  62. };
  63.  
  64. //========================================================================
  65. //   ShrapnelToggleWeapon
  66. //========================================================================
  67.  
  68. void(entity player) ShrapnelToggleWeapon =
  69. {
  70.   if (!USE_MODULE_SHRAPNEL) return;
  71.   
  72.   if (player.modules_weapon & MODULES_WEAPON_SHRAPNEL) {
  73.     player.modules_weapon = player.modules_weapon - MODULES_WEAPON_SHRAPNEL;
  74.     player.items = player.items - (player.items & IT_KEY1);
  75.   } else {
  76.     if ((player.weapon == IT_ROCKET_LAUNCHER) && (player.ammo_rockets >= 1)) {
  77.       player.modules_weapon = player.modules_weapon | MODULES_WEAPON_SHRAPNEL;
  78.       player.items = player.items | IT_KEY1;
  79.     }
  80.   }
  81. };
  82.  
  83. //========================================================================
  84. //   ShrapnelResetWeapon
  85. //========================================================================
  86.  
  87. void(entity player) ShrapnelResetWeapon =
  88. {
  89.   if (!USE_MODULE_SHRAPNEL) return;
  90.   if (player.modules_weapon & MODULES_WEAPON_SHRAPNEL) {
  91.     player.modules_weapon = player.modules_weapon - MODULES_WEAPON_SHRAPNEL;
  92.     player.items = player.items - (player.items & IT_KEY1);
  93.   }
  94. };
  95.  
  96. //==================================================================
  97. //   ShrapnelMissileFire
  98. //==================================================================
  99.  
  100. void() ShrapnelMissileFire =
  101. {
  102.   local entity proj,flame;
  103.   
  104.   self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  105.   self.punchangle_x = -2;
  106.   makevectors (self.v_angle);
  107.   
  108.   proj                 = spawn();
  109.   proj.classname       = "shrapnel_projectile";
  110.   proj.owner           = self;
  111.   proj.shrapnel_owner  = self;
  112.   proj.movetype        = MOVETYPE_FLYMISSILE;
  113.   proj.solid           = SOLID_BBOX;
  114.   proj.velocity        = aim(self,850);
  115.   proj.velocity        = proj.velocity * 850;
  116.   proj.angles          = vectoangles(proj.velocity);
  117.   proj.angles_x        = proj.angles_x + 180;
  118.   proj.touch           = ShrapnelMissileTouch;
  119.   proj.think           = SUB_Remove;
  120.   proj.nextthink       = time + 6;
  121.   proj.ltime           = time + 6;
  122.   proj.modules_weapon  = MODULES_WEAPON_SHRAPNEL;
  123.   setmodel(proj, "progs/grenade.mdl");
  124.   setsize(proj, '0 0 0', '0 0 0');        
  125.   setorigin(proj, self.origin + v_forward*36 + '0 0 14');
  126.  
  127.   flame           = spawn();
  128.   flame.classname = "shrapnel_flame";
  129.   flame.owner     = proj.owner;
  130.   flame.origin    = proj.origin;
  131.   flame.velocity  = proj.velocity;
  132.   flame.movetype  = proj.movetype;
  133.   flame.solid     = proj.solid;
  134.   flame.think     = SUB_Remove;
  135.   flame.touch     = SUB_Remove;
  136.   flame.nextthink = proj.ltime;
  137.   flame.ltime     = proj.ltime;
  138.   flame.angles     = vectoangles(flame.velocity);
  139.   flame.angles_x   = flame.angles_x + 90;
  140.   flame.frame      = 1;
  141.   setmodel (flame, "progs/flame2.mdl");
  142.   setsize (flame, '0 0 0', '0 0 0');
  143.   setorigin(flame, self.origin + v_forward*18 + '0 0 14');
  144.   
  145.   sound (self, CHAN_WEAPON, shrapnel_launch_sound_1, 0.7, ATTN_NORM);
  146.   sound (proj, CHAN_BODY  , shrapnel_launch_sound_2, 1, ATTN_NORM);
  147. };
  148.  
  149. //==================================================================
  150. //   ShrapnelBounceDirection
  151. //==================================================================
  152.  
  153. void() ShrapnelBounceDirection =
  154. {
  155.   local vector vo,vn;
  156.  
  157.   vn = normalize(self.velocity);
  158.   vo = self.origin - vn;
  159.   vn = self.origin + vn;
  160.   traceline(vo, vn, TRUE,self);
  161.   v_forward = normalize(self.velocity - 2*(self.velocity*trace_plane_normal)*trace_plane_normal);
  162.   v_forward_z = v_forward_z * (-1);  // ?????????????
  163. };
  164.  
  165. //==================================================================
  166. //   ShrapnelMissileTouch
  167. //==================================================================
  168.  
  169. void() ShrapnelMissileTouch =
  170. {
  171.   local float damg,r;
  172.   local vector v;
  173.  
  174.   //dprint("ShrapnelMissileTouch\n");
  175.  
  176.   if (pointcontents(self.origin) == CONTENT_SKY) {
  177.     remove(self);
  178.     return;
  179.   }
  180.  
  181.   sound (self, CHAN_WEAPON, shrapnel_explode_sound, 0.7, ATTN_NORM);
  182.  
  183.   if (other.solid == SOLID_BSP) {
  184.     r = random();
  185.     damg = 30 + r*10;
  186.     T_RadiusDamage (self,self.owner,damg,world);
  187.     if (r > 0.5) BurnSetOnFire(other,self.owner);    //#jp#(Burn)
  188.   }
  189.  
  190.   ShrapnelBounceDirection();
  191.   v = vectoangles(v_forward);
  192.   makevectors(v);
  193.   v = v_forward;
  194.   ShrapnelDebrisFire(v_forward);
  195.   v = normalize(v_forward + 1.5*(0.5-random())*v_up + 1.5*(0.5-random())*v_right); 
  196.   ShrapnelDebrisFire(v);
  197.   v = normalize(v_forward + 1.5*(0.5-random())*v_up + 1.5*(0.5-random())*v_right); 
  198.   ShrapnelDebrisFire(v);
  199.   if (r>0.5) {
  200.     v = normalize(v_forward + 1.5*(0.5-random())*v_up + 1.5*(0.5-random())*v_right); 
  201.      ShrapnelDebrisFire(v);
  202.   }
  203.   self.origin = self.origin - 4 * normalize(self.velocity);
  204.   BecomeExplosion();
  205. };
  206.  
  207. //==================================================================
  208. //   ShrapnelDebrisFire
  209. //==================================================================
  210.  
  211. float SHRAPNEL_DEBRIS_VELOCITY = 600;
  212.  
  213. entity(vector vel) ShrapnelDebrisFire =
  214. {
  215.    local entity debris;
  216.  
  217.    debris = spawn();
  218.    debris.origin         = self.origin;
  219.    debris.classname      = "shrapnel_debris";
  220.    debris.owner          = world;
  221.    debris.shrapnel_owner   = self.shrapnel_owner;
  222.    debris.velocity       = vel*SHRAPNEL_DEBRIS_VELOCITY;
  223.    debris.angles         = vectoangles(debris.velocity);
  224.    debris.angles_x       = debris.angles_x + 90;
  225.    debris.movetype       = MOVETYPE_FLYMISSILE;
  226.    debris.solid          = SOLID_BBOX;
  227.    debris.think          = ShrapnelDebrisThink;
  228.    debris.touch          = ShrapnelDebrisTouch;
  229.    debris.ltime          = time + 0.7 + random()*0.3;
  230.    debris.nextthink      = debris.ltime + 2;
  231.    debris.modules_weapon = MODULES_WEAPON_SHRAPNEL;
  232.    debris.effects        = EF_DIMLIGHT;
  233.    setmodel (debris, "progs/flame2.mdl");
  234.    setsize (debris, '0 0 0', '0 0 0');
  235.    setorigin (debris, debris.origin);
  236.    return(debris);
  237. };
  238.  
  239. //==================================================================
  240. //   ShrapnelDebrisExplode
  241. //==================================================================
  242.  
  243. void() ShrapnelDebrisExplode1 = [0, ShrapnelDebrisExplode2] {};
  244. void() ShrapnelDebrisExplode2 = [3, ShrapnelDebrisExplode3] {};
  245. void() ShrapnelDebrisExplode3 = [4, SUB_Remove]   {};
  246.  
  247. float SHRAPNEL_DAMAGE_RADIUS = 70;
  248.  
  249. void(float do_damage) ShrapnelDebrisExplode = 
  250. {
  251.   local entity e;
  252.   local float r,d,db;
  253.  
  254.   if (do_damage) {
  255.     self.owner = self.shrapnel_owner;
  256.     if (other.takedamage) { spawn_touchblood (9); }
  257.     e = findradius(self.origin, SHRAPNEL_DAMAGE_RADIUS);
  258.     while (e) {
  259.       if (e.takedamage) {
  260.     if (e.takedamage != DAMAGE_AIM) {
  261.       T_Damage (e, self, self.owner, 10);
  262.     } else {
  263.       r  = random();
  264.       db = 25 + (0.5 - r)*5;
  265.       d  = vlen(e.origin + '0 0 16' - self.origin);
  266.       if      (d<SHRAPNEL_DAMAGE_RADIUS - 2*db) d = db;
  267.       else if (d<SHRAPNEL_DAMAGE_RADIUS) d = (SHRAPNEL_DAMAGE_RADIUS-d)*0.5;
  268.       else d = 0;
  269.       if (d) {
  270.         T_Damage (e, self, self.owner, d);
  271.         if (r > 0.66) {            //#jp#(Burn)
  272.           if (d > 6) {            //#jp#(Burn)
  273.         BurnSetOnFire(e,self.owner);    //#jp#(Burn)
  274.           }                    //#jp#(Burn)
  275.         }                    //#jp#(Burn)
  276.       }
  277.     }
  278.       }
  279.       e = e.chain;
  280.     }
  281.     self.owner   = world;
  282.   }
  283.  
  284.   self.classname = "shrapnel_explosion";
  285.   self.origin    = self.origin - 4 * normalize(self.velocity);
  286.   self.movetype  = MOVETYPE_NONE;
  287.   self.velocity  = '0 0 0';
  288.   self.touch     = SUB_Null;
  289.   self.solid     = SOLID_NOT;
  290.   self.think     = SUB_Remove;  // be on the
  291.   self.nextthink = time + 4;    // safe side
  292.   setmodel(self, "progs/s_explod.spr");
  293.   setorigin(self, self.origin);
  294.  
  295.   ShrapnelDebrisExplode1();
  296. };
  297.  
  298.  
  299. //==================================================================
  300. //   ShrapnelDebrisTouch
  301. //==================================================================
  302.  
  303. void() ShrapnelDebrisTouch =
  304. {
  305.   local float r,do_damage,play_sound;
  306.   local vector v;
  307.   local entity e, self_old;
  308.  
  309.   //dprint("lamerDebrisTouch"\n);
  310.   //dprint(other.classname); dprint("\n");
  311.  
  312.   if (pointcontents(self.origin) == CONTENT_SKY) {
  313.     remove(self);
  314.     return;
  315.   }
  316.  
  317.   if (time > self.shrapnel_bounce_time + 0.1) {
  318.     ShrapnelBounceDirection();
  319.     self.movetype  = MOVETYPE_BOUNCE;
  320.     self.velocity  = self.velocity + (v_forward*self.velocity)*v_forward;
  321.     self.nextthink = time;
  322.     self.angles    = vectoangles(self.velocity);
  323.     self.angles_x  = self.angles_x + 90;
  324.   } else self.ltime = time;
  325.  
  326.   do_damage  = FALSE;
  327.   play_sound = 0;
  328.   if (other.solid != SOLID_BSP) {
  329.     e = self;
  330.     do_damage = TRUE;
  331.     play_sound = 1;
  332.   }
  333.   else if (time < self.ltime) {
  334.     if (time > self.shrapnel_damage_time + 0.1) {
  335.       do_damage = TRUE;
  336.       self.shrapnel_damage_time = time;
  337.     }
  338.     if (time > self.shrapnel_sound_time + 0.1) {
  339.       self.shrapnel_sound_time = time;
  340.       play_sound = 1;
  341.     }
  342.     e                = spawn();
  343.     e.origin         = self.origin;
  344.     e.velocity       = self.velocity;
  345.     e.shrapnel_owner   = self.shrapnel_owner;
  346.     e.modules_weapon = MODULES_WEAPON_SHRAPNEL;
  347.     e.effects        = EF_DIMLIGHT;
  348.     setsize (e, '0 0 0', '0 0 0');
  349.   } else {
  350.     e = self;
  351.     play_sound = 1;
  352.     do_damage = TRUE;
  353.   }
  354.   self_old = self;
  355.   self = e;
  356.   if (play_sound) sound (self, CHAN_WEAPON, shrapnel_explode_sound, 0.6, ATTN_NORM);
  357.   ShrapnelDebrisExplode(do_damage);
  358.   self = self_old;
  359. };
  360.  
  361. //==================================================================
  362. //   ShrapnelDebrisThink
  363. //==================================================================
  364.  
  365. void() ShrapnelDebrisThink =
  366. {
  367.   local entity other_old;
  368.  
  369.   if (time < self.ltime + 2) {
  370.     if (vlen(self.velocity) > 100) {
  371.       self.flags     = self.flags - (self.flags & FL_ONGROUND);
  372.       self.velocity  = normalize(self.velocity) * SHRAPNEL_DEBRIS_VELOCITY;
  373.       self.movetype  = MOVETYPE_FLYMISSILE;
  374.       self.nextthink = self.ltime + 2;
  375.       self.angles    = vectoangles(self.velocity);
  376.       self.angles_x  = self.angles_x + 90;
  377.       return; 
  378.     }
  379.   }
  380.   other_old = other;
  381.   ShrapnelDebrisExplode(TRUE);
  382.   other = other_old;
  383. };
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.